<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="button" value="斐波那契数列" onclick="test()" />
    <script>
        //  1、斐波那契数列：1，1，2，3，5，8 。。。。从第三项开始每项都等于前两项之和。
        function test() {
            var n1 = 1;
            var n2 = 1;
            var n3;
            for (var i = 2; i < 20; i++) {
                n3 = n1 + n2;
                document.write(n3);
                n1 = n2;
                n2 = n3;
                document.write("<br/>")
            }
        }
    </script>
</body>

</html>